#ifndef SPRITE_H_
#define SPRITE_H_

#include <d3d9.h>
#include <d3dx9.h>
#include "Camera.h"

class CSprite
{
protected:
	LPDIRECT3DTEXTURE9 m_texture;
	RECT m_rect;
	int m_index;
	int m_totalTiled;
	int m_columnTiled;
	int m_widthTiled;
	int m_heightTiled;
	int m_widthImage;
	int m_heightImage;

	bool m_running;
	int m_duration;
	int m_durationCount;
	int m_firstIndex;
	int m_lastIndex;
	int m_loopTotal; 
	int m_loopCount;
	bool m_flag;
	bool m_flipY;
	int m_indexStop;

	D3DXVECTOR2 m_Pos;


public:


	//------constructor--------------- 
	CSprite(void);
	CSprite( int _widthImage, int _heightImage, int _total,int _column);
	CSprite(int _width, int _height);
	~CSprite(void);
	//---------Function---------------
	void init(LPDIRECT3DTEXTURE9);

	void draw(LPD3DXSPRITE);
	void draw(LPD3DXSPRITE, float posX, float posY, bool flipY);
	void draw(LPD3DXSPRITE, D3DXVECTOR2,bool flipY);
	void draw(LPD3DXSPRITE sp, D3DXVECTOR2 _pos, D3DCOLOR _color);
	void draw(LPD3DXSPRITE sp, D3DXVECTOR2 _pos, D3DCOLOR _color,bool flipY);	
	void draw(LPD3DXSPRITE, D3DXVECTOR2, D3DXVECTOR3);

	void setRECT(int);
	void setRECT();
	void setRECT(RECT x){ m_rect = x; }
	void setRECT(int, int, int, int);

	void update();
	// lap mai k xet de m_loopTotal va m_loopCount
	void updateLoop();


	void animate(int _duration, int _fist, int _last, int _loop, int _indexStop);
	void animate(int _duration, int _fist, int _last, int _loop);
	void animate(int _duration, int _fist, int _last, int _loop, bool _flag);	
	void animate(int _duration, int _fist, int _last);
	void animate(int _duration, int _loop);
	void animate();

	void stopAnimate();
	void stopAnimate(int i);


	RECT getRect();
	int getTotalFrame();
	void setTotalFrame();
	int getIndex() { return m_index; }
	void setIndex(int _i) { m_index = _i; }
	int getWidthTiled(){ return m_widthTiled; }
	void setWidthTiled(int x){ m_widthTiled; }
	int getHeightTiled() { return m_heightTiled; }
	void setHeightTiled(int x){ m_heightTiled = x; }
	int getHeightImage();
	int getWidthImage();

	bool isRunning() { return m_running; }
	void setRunning(bool _is){ m_running = _is; }

	bool isFlipY() { return m_flipY; }
	void setFlipY(bool _is){ m_flipY = _is; }

	int getDuration();
	void setDuration();
	int getFirstIndex();
	void setFirstIndex();
	int getLastIndex();
	void setLastIndex();
	int getLoopTotal();
	void setLoopTotal();
	void addLoopTotal(int x){ m_loopTotal += x; };
	int getLoopCount(){ return m_loopCount; }
	void setLoopCount();

	void setPostion(D3DXVECTOR2 x){ m_Pos = x; };
	D3DXVECTOR2 getPostion(){ return m_Pos; };


};
#endif
